﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Factonomy.AzureStorageUtility.WindowsApp
{
    public delegate void NoParameterDelegate();
    public delegate void ParameterDelegate(object sender);
    public delegate object NoParameterReturnDelegate();
    public delegate string NoParameterStringDelegate();
    public delegate object ParameterReturnDelegate(object sender);
    public delegate void IntParameterDelegate(int sender);

    class Globals
    {
        public enum UpdateUiEvent
        {
            ContainerClicked,
            AccountClicked,
            LoadError,
            BlobClicked
        }

        public static string AppName
        {
            get { return "Factonomy Windows Azure Storage Utility"; }
        }

        public static string RootPathSettingName
        {
            get { return "rootpath"; }
        }

        public static string RootPathSetting
        {
            get { return ConfigurationManager.AppSettings[RootPathSettingName]; }
        }

        public static string AutoRefreshContainersSettingName
        {
            get { return "autorefreshcontainers"; }
        }

        public static string AutoRefreshContainersSetting
        {
            get { return ConfigurationManager.AppSettings[AutoRefreshContainersSettingName]; }
        }

        public static string AutoRefreshBlobsSettingName
        {
            get { return "autorefreshblobs"; }
        }

        public static string AutoRefreshBlobsSetting
        {
            get { return ConfigurationManager.AppSettings[AutoRefreshBlobsSettingName]; }
        }

        public static string DefaultAccountSettingName
        {
            get { return "defaultaccount"; }
        }

        public static string DefaultAccountSetting
        {
            get { return ConfigurationManager.AppSettings[DefaultAccountSettingName]; }
        }

        public static bool CanEditInTextEditor(string extension)
        {
            switch (extension)
            {
                case ".rtf":
                    return true;
                case ".txt":
                    return true;
                case ".xsd":
                    return true;
                case ".xsl":
                    return true;
                case ".xslt":
                    return true;
                case ".xml":
                    return true;
                case ".css":
                    return true;
                case ".js":
                    return true;
                default:
                    return false;
            }
        }

        public static string GetHttpContentType(string extension)
        {
            switch (extension)
            {
                case ".dot":
                    return "application/msword";
                case ".doc":
                    return "application/msword";
                case ".avi":
                    return "video/avi";
                case ".mov":
                    return "video/quicktime";
                case ".mp3":
                    return "audio/mpeg3";
                case ".mpp":
                    return "video/mp4";
                case ".pps":
                    return "application/mspowerpoint";
                case ".rtf":
                    return "application/rtf";
                case ".tif":
                    return "image/tiff";
                case ".txt":
                    return "plain/text";
                case ".wav":
                    return "audio/wav";
                case ".xls":
                    return "application/excel";
                case ".zip":
                    return "application/zip";
                case ".xsd":
                    return "text/xml";
                case ".xsl":
                    return "application/xml";
                case ".xslt":
                    return "application/xml";
                case ".xml":
                    return "text/xml";
                case ".css":
                    return "text/css";
                case ".bmp":
                    return "image/bmp";
                case ".gif":
                    return "image/gif";
                case ".jpeg":
                    return "image/jpeg";
                case ".jpg":
                    return "image/jpeg";
                case ".png":
                    return "image/png";
                case ".x-png":
                    return "image/png";
                case ".js":
                    return "application/x-javascript";
                case ".pdf":
                    return "application/pdf";
                case ".ico":
                    return "image/x-icon";
                case ".flv":
                    return "video/x-flv";
                case ".wmv":
                    return "audio/x-ms-wmv";
                case ".swf":
                    return "application/x-shockwave-flash";
                default:
                    return "text/html";
            }
        }
    }
}
